package com.cooper.mediadb.online;

import android.util.Log;

import com.cooper.scraper.DownloadException;
import com.cooper.scraper.DownloadParams;
import com.cooper.scraper.RunnerThread;
import com.cooper.scraper.ScraperException;

public class AnalyzeVideoThread extends RunnerThread {

	private AnalyzeVideo analyzeVideo;
	private String url;

	public AnalyzeVideoThread(DownloadParams params, MediaSource sources, String format) {
		super(params);
		this.url = sources.getUrl();
		analyzeVideo = AnalyzeVideo.createAnalyzeVideo(httpDownload, sources,
				format);
	}

	@Override
	public void run() {
		super.run();
		try {
			complete(url,analyzeVideo.analyzeVideo());
		} catch (DownloadException e) {
			fail(url, e.getErrorCode());
		} catch (ScraperException e) {
			fail(url, e.getErrorCode());
		} catch (Exception e) {
			Log.e("DownloadMediaDetails.run", e.getMessage(), e);
			fail(url, DownloadException.ERROR_OTHER);
		}
	}
}
